<?php
declare (strict_types=1);

namespace app\controller\v1;

use app\model\UserDetails;
use think\annotation\route\Group;
use think\annotation\Route;
use app\serviceapp\IndexService;
use think\facade\Cache;

/**
 * 非用户身份类接口
 * Class Index
 * @package app\controller\v1
 * @Group("v1/index")
 */
class Index extends Base
{
    /**
     * 获取所有引导参数
     * @Route("guideList", method="GET")
     */
    public function guideList()
    {
        $data['type'] = input('get.type', '', 'string');
        $res = IndexService::getLists($data);
        return json_ok(formatData(['list' => $res]), 0);
    }

    /**
     * 设置向导
     * @Route("guideOneToFour", method="POST")
     */
    public function guideOneToFour()
    {
        $data['type'] = input('post.type', '', 'int');
        $data['user_id'] = $this->request->dani_user['user_id'];
        $data['selectedParam'] = input('post.selectedParam');
        if (empty($data['type']) || empty($data['user_id']) || empty($data['selectedParam'])) return json_error(10002);

        $res = IndexService::setting($data);
        return json_ok($res, 0);
    }

    /**
     * 设置向导
     * @Route("guideFive", method="POST")
     */
    public function guideFive()
    {
        $data['user_id'] = $this->request->dani_user['user_id'];
        $data['info'] = input('info');
        if (empty($data['info'])) return json_error(10002);

        $res = IndexService::setPersonInfo($data);
        return json_ok($res, 0);
    }

    /**
     * 获取用户的身材信息
     * @Route("userDetailInfo", method="GET")
     */
    public function userDetailInfo()
    {
        $user_id = $this->request->dani_user['user_id'];
        if (!$user_id) return json_error(10002);

        $res = IndexService::getUserDetailInfo($user_id);
        return json_ok(formatData($res), 0);
    }
}
